﻿<%@ Page Language="C#" AutoEventWireup="true"  EnableSessionState="True" Inherits="cn_goods" Codebehind="goods.aspx.cs" %>


<%@ Register Src="~/cn/UserControl/header.ascx" TagName="header" TagPrefix="uc1" %>
<%@ Register Src="~/cn/UserControl/top_ad.ascx" TagName="top_ad" TagPrefix="uc2" %>
<%@ Register Src="~/cn/UserControl/footer.ascx" TagName="footer" TagPrefix="uc3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title><%=KeywordsBind() %><%=(new Gift.WebApp.BasicSet()).TitleBind() %></title>
    <meta name="Keywords" content="<%=KeywordsBind() %><%=(new Gift.WebApp.BasicSet()).KeywordBind() %>" />
    <meta name="Description" content="<%=DescriptionBind() %><%=(new Gift.WebApp.BasicSet()).DescriptionBind() %>" />
    <link href="/script/css/layout.css" type="text/css" rel="stylesheet" />
    <link href="/script/art_dialog/skins/idialog.css" rel="stylesheet" />
    <script src="/script/js/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="/script/js/showpro/cloud-zoom.1.0.2.js" type="text/javascript"></script>


  



    <script type="text/javascript">
        $(function () {
            $("#btnGoodsComment").click(function () {
                if ($("#txtaContent").val() == "") {
                    $("#txtaContent").select();
                    $("#spContent").html("<img src=\"/script/images/wrong.gif\" />请输入评论内容！");
                    return false;
                } else {
                    if ($("#txtaContent").val().length > 500) {
                        $("#txtaContent").select();
                        $("#spContent").html("<img src=\"/script/images/wrong.gif\" />评论内容不能超过500个字符！");
                        return false;
                    } else $("#spContent").html("<img src=\"/script/images/right.gif\" />");
                }
                if ($("#txtCommentCode").val() == "") {
                    $("#txtCommentCode").select();
                    $("#spCommentCode").html("<img src=\"/script/images/wrong.gif\" />请输入验证码！");
                    return false;
                } else $("#spCommentCode").html("<img src=\"/script/images/right.gif\" />");
                $.ajax({
                    type: "POST",
                    url: "goodsCommentHandler.ashx",
                    data: "id=" + $("#hdGoods").val() + "&contact=" + escape($("#txtContact").val()) + "&content=" + escape($("#txtaContent").val()) + "&code=" + $("#txtCommentCode").val(),
                    success: function (msg) {
                        if (msg == "0") {
                            TB_show(null, "login.html?TB_iframe=true&height=370&width=640", false);
                        } else if (msg == "1") {
                            $("#txtCommentCode").select();
                            $("#spCommentCode").html("<img src=\"/script/images/wrong.gif\" />验证码错误，请重新输入！");
                            $("#imgCheckCommentCode").attr("src", "/code.aspx?a=" + Math.random() + "&t=conmment");
                        } else if (msg == "2") {
                            art.dialog.tips("很抱歉，评论失败！", 1.5);
                        }
                        else {
                            art.dialog.tips("恭喜您，评论成功！", 1.5);
                            $("#goods_comment").html(msg);
                            $('#formComment')[0].reset(); //表单重置
                            $("#spContent").html("*最多可输入200个字符");
                            $("#spCommentCode").html("");
                            $("#imgCheckCommentCode").attr("src", "/code.aspx?a=" + Math.random() + "&t=conmment");
                        }
                    }
                });
                return false;
            });
            $("#btnScoreSubmit").click(function () {
                if ($("input[name='commodityScore']:checked").val() == null) {
                    art.dialog.tips("请选择星级！", 1.5);
                    //                    $("#spCommodityScore").html("<img src=\"/script/images/wrong.gif\" />请选择星级！");
                    return false;
                } else {
                    $.ajax({
                        type: "POST",
                        url: "commodityScoreHandler.ashx",
                        data: "id=" + $("#hdGoods").val() + "&score=" + $("input[name='commodityScore']:checked").val(),
                        success: function (msg) {
                            //                            $("#spCommodityScore").html("");
                            if (msg == "0") {
                                TB_show(null, "login.html?TB_iframe=true&height=370&width=640", false);
                            }
                            else if (msg == "1") {
                                art.dialog.tips("很抱歉，评分失败！", 1.5);
                            } else {
                                art.dialog.tips("恭喜您，评分成功！", 1.5);
                                $('#formScore')[0].reset(); //表单重置
                                $("#pScore").html(msg.split("+")[0]);
                                $("#divScore").html(msg.split("+")[1]);
                            }
                        }
                    });
                    return false;
                }
            });
            $("#btnCountJian").click(function () {
                if (parseInt($("#txtCount").val()) > 0)
                    $("#txtCount").val(parseInt($("#txtCount").val()) - 1);
            });
            $("#btnCountJia").click(function () {
                if (parseInt($("#spInventory").text()) > parseInt($("#txtCount").val()))
                    $("#txtCount").val(parseInt($("#txtCount").val()) + 1);
            });
            ///商品收藏
            $("#aFavorites").click(function () {
                $.ajax({
                    type: "POST",
                    url: "goodsFavoritesHandler.ashx",
                    data: "id=" + $("#hdGoods").val(),
                    success: function (msg) {
                        if (msg == "0") TB_show(null, "login.html?TB_iframe=true&height=370&width=640", false);
                        else if (msg == "1") art.dialog.tips("此商品已收藏，请不要重复添加！", 1.5);
                        else if (msg == "2") art.dialog.tips("恭喜您，收藏成功！", 1.5);
                        else if (msg == "3") art.dialog.tips("很抱歉，收藏失败！", 1.5);
                    }
                });
                return false;
            });
            $("#aAddShoppingCart").click(function () {

                if ($("#txtCount").val() == "0") {
                    art.dialog.tips("请输入购买数量！", 1.5);
                    return false;
                }
                else {
                    $.ajax({
                        type: "POST",
                        url: "addShoppingCartHandler.ashx",
                        data: "goodsEntitys=" + $("#hdGoodsEntitys").val() + "&count=" + $("#txtCount").val(),
                        success: function (msg) {
                            if (msg == "0") customButton('添加至购物车成功！', '立即结算', 'shopping_cart.html', '继续购物');
                            else if (msg == "1") art.dialog.tips("添加购物车失败，商品库存不足！", 1.5);

                        }
                    });
                }
                return false;
            });
        });
        function send_request(url, poststr) {
            http_request = false;
            if (window.XMLHttpRequest) {
                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                    http_request.overrideMimeType('text/xml');
                }
            } else if (window.ActiveXObject) {
                try {
                    http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                        http_request = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) { }
                }
            }
            if (!http_request) return false;
            http_request.onreadystatechange = processRequest;
            http_request.open("POST", url, true);
            http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            http_request.send(poststr);
        }
        function processRequest() {
            if (http_request.readyState == 4) {
                if (http_request.status == 200) {
                    if (http_request.responseText != "") {
                        var returnValue = http_request.responseText.split("+");
                        $("#goodsArtno").text(returnValue[0]);
                        $("#pPrice").html(returnValue[1]);
                        $("#spInventory").html(returnValue[2]);
                        if (parseInt(returnValue[2]) > 0) $("#txtCount").val("1");
                        else $("#txtCount").val("0");
                        $("#hdSpecificationsValueList").val(returnValue[3]);
                        $("#liChooseSpecifications").html(returnValue[4]);
                        $("#liSpecifications").html(returnValue[5]);
                        $("#hdGoodsEntitys").val(returnValue[6]);
                    }
                } else { }
            }
        }
        function chooseSpecifications(ge, s, sv) {
            poststr = "goodsEntitys=" + ge + "&specifications=" + s + "&specificationsValue=" + sv + "&goods=" + $("#hdGoods").val() + "&SpecificationsList=" + $("#hdSpecificationsList").val() + "&SpecificationsValueList=" + $("#hdSpecificationsValueList").val();
            send_request('specificationsHandler.ashx', poststr);
            return false;
        }
        function send_request1(url, poststr) {
            http_request = false;
            if (window.XMLHttpRequest) {
                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                    http_request.overrideMimeType('text/xml');
                }
            } else if (window.ActiveXObject) {
                try {
                    http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                        http_request = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) { }
                }
            }
            if (!http_request) return false;
            http_request.onreadystatechange = processRequest1;
            http_request.open("POST", url, true);
            http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            http_request.send(poststr);
        }
        function processRequest1() {
            if (http_request.readyState == 4) {
                if (http_request.status == 200) {
                    if (http_request.responseText != "") {
                        $("#pFreight").html(http_request.responseText);
                    }
                } else { }
            }
        }
        function changeFreight(fid, rn, name) {
            poststr = "fid=" + fid + "&rn=" + escape(rn);
            send_request1('freightWayHandler.ashx', poststr);
            $("#region").html(name);
            $("a[s]").removeClass('sbg');
            $(".city").hide();
            $("#storeinfo").removeClass('hover');
            return false;
        }
    </script>

</head>
<body>
    <uc1:header ID="Header1" runat="server" />
    <uc2:top_ad ID="Top_ad1" runat="server" />
    <div class="container">

      <div class="sidebar" >
            <%Response.Write(CategoryTopSellingBind()); %>
            <!--end 商品列表-->
            <%Response.Write(UserBrowseBind()); %>
            <!--end 商品列表-->
            <%Response.Write(RecentBrowseBoodsBind()); %>
            <!--end 商品列表-->
        </div>


        <%Response.Write(GoodGalleryBind()); %>
        <!--产品动画结束-->
        <%Response.Write(SetSpecificationsValueList()); %>
        <%Response.Write(GoodsEntitysBind()); %>
          <!--end sidebar-->
        <%Response.Write(GoodsDetailedBind()); %>
        <span class="clear"></span>
    </div>

    <uc3:footer ID="Footer1" runat="server" />
</body>
</html>
